package o;

import android.content.Context;
import android.text.TextUtils;
import com.huawei.appgallery.foundation.account.bean.UserSession;
import org.json.JSONException;
import org.json.JSONObject;

public class cug {
    public static void ˎ(final Context context, final String str) {
        try {
            JSONObject jSONObject = new JSONObject(str);
            if (ˎ(jSONObject)) {
                Logger.ˎ("PushAccountIntercepter", "needAccountIntercpt = true");
                jSONObject = jSONObject.getJSONObject("param");
                if (jSONObject == null || !jSONObject.has("accountId")) {
                    Logger.ˋ("PushAccountIntercepter", "msgParaJson is null or has not  accountId param!");
                    return;
                }
                final String string = jSONObject.getString("accountId");
                if (UserSession.getInstance().isLoginSuccessful()) {
                    Object userId = UserSession.getInstance().getUserId();
                    Logger.ˎ("PushAccountIntercepter", "local state is login,accountIntercept pushAccountId");
                    if (!TextUtils.isEmpty(userId) && userId.equals(string)) {
                        Logger.ˎ("PushAccountIntercepter", "accountIntercept localAccountID = accountId , to run PushNotificationTask");
                        ˋ(context, str);
                        return;
                    }
                    return;
                }
                boolean ˋ = eod.ˋ(context);
                Logger.ˎ("PushAccountIntercepter", "local state is not login,accountIntercept hasAccounts =" + ˋ);
                if (ˋ) {
                    eoj.ˋ().ˎ("PushAccountIntercepter", new AccountBussinessListener() {
                        public void onAccountBusinessResult(ccp o_ccp) {
                            if (102 == o_ccp.ˎ) {
                                Object userId = UserSession.getInstance().getUserId();
                                if (!TextUtils.isEmpty(userId) && userId.equals(string)) {
                                    Logger.ˎ("PushAccountIntercepter", "accountIntercept OnLoginCallBack onLogin , to run PushNotificationTask");
                                    cug.ˋ(context, str);
                                }
                            }
                            eoj.ˋ().ˊ("PushAccountIntercepter");
                            Logger.ˎ("PushAccountIntercepter", "AccountObserver accountResult=" + o_ccp);
                        }
                    });
                    Logger.ˎ("PushAccountIntercepter", "accountIntercept AccountManagerHelper.login");
                    eod.ॱ(ContentManager.getInstant().getContext());
                    return;
                }
                return;
            }
            Logger.ˎ("PushAccountIntercepter", "needAccountIntercpt = false，to run PushNotificationTask");
            ˋ(context, str);
        } catch (JSONException e) {
            Logger.ˎ("PushAccountIntercepter", "JSONException");
        }
    }

    private static boolean ˎ(JSONObject jSONObject) throws JSONException {
        String string = jSONObject.getString("cmd");
        if ("commentReply".equals(string) || "bindPhone".equals(string) || "wishDetail".equals(string) || "addWishInfo".equals(string) || "addGameReserveInfo".equals(string)) {
            return true;
        }
        return false;
    }

    private static void ˋ(Context context, String str) {
        cue ˎ = cty.ˎ().ˎ("14");
        if (ˎ != null) {
            ˎ.ˋ(context, str);
        }
    }
}
